<template>
  <basic-container>
    <!--    <avue-tabs :option="tabOption" @change="handleChange"></avue-tabs>-->
    <span v-if="type.prop==='task_general_basic'">
            <avue-crud :option="option"
                       :table-loading="loading"
                       :data="data"
                       ref="crud"
                       v-model="form"
                       :permission="permissionList"
                       :page.sync="page"
                       @search-change="searchChange"
                       @search-reset="searchReset"
                       @current-change="currentChange"
                       @size-change="sizeChange"
                       @refresh-change="refreshChange"
                       @on-load="onLoad">
                <template slot="menuRight" slot-scope="scope">
                  <el-button type="danger" size="small" @click="excelBox=true">导入环节</el-button>
                </template>
                <template slot="menu" slot-scope="scope">
                  <el-button type="text" size="small" icon="el-icon-view" @click="handView(scope.row)">查看
                                    </el-button>
                  <!--                  <el-button type="text" size="small" icon="el-icon-time"-->
                  <!--                             @click="historyEvent(scope.row)">历史版本</el-button>-->
                  <el-button type="text" icon="el-icon-set-up" size="small"
                             @click="itemLevel(scope.row)">业务环节</el-button>
                  <!--                  <el-button v-if="scope.row.isSendsms=='0' " type="text" size="small" @click="isSendsms(scope.row,'1')">启用短信</el-button>
                                    <el-button v-if="scope.row.isSendsms=='1' " type="text" size="small" @click="isSendsms(scope.row,'0')">禁用短信</el-button>-->
                  <!--                  <el-button type="text" icon="el-icon-tickets" size="small"-->
                  <!--                             @click="baseConfigure(scope.row)">事项基本配置</el-button>-->
                  <!--                  <el-button type="text" icon="el-icon-tickets" size="small" @click="shiXiangVisible1(scope.row,val=0)"-->
                  <!--                             :disabled="scope.row.itemLevel == '6' || scope.row.itemLevel == '7' ?  false : true">部门对接管理</el-button>-->
                </template>
                <template slot-scope="scope" slot="promiseDay">
                    {{ scope.row.promiseDay + '工作日' }}
                </template>
            </avue-crud>
    </span>
    <!--    <span v-else-if="type.prop==='task_public_basic'">-->
    <!--            <avue-crud :option="option2"-->
    <!--                       :table-loading="loading"-->
    <!--                       :data="data"-->
    <!--                       ref="crud"-->
    <!--                       v-model="form"-->
    <!--                       :permission="permissionList"-->
    <!--                       :page.sync="page"-->
    <!--                       @search-change="searchChange"-->
    <!--                       @search-reset="searchReset"-->
    <!--                       @current-change="currentChange"-->
    <!--                       @size-change="sizeChange"-->
    <!--                       @refresh-change="refreshChange"-->
    <!--                       @on-load="onLoad">-->
    <!--                <template slot="menuRight" slot-scope="scope">-->
    <!--                  <el-button type="danger" size="small" @click="excelBox=true">导入环节</el-button>-->
    <!--                </template>-->
    <!--                <template slot="menu" slot-scope="scope">-->
    <!--                  <el-button type="text" icon="el-icon-tickets" size="small"-->
    <!--                             @click="guideShowStatus(scope.row)">详情</el-button>-->
    <!--                  <el-button type="text" size="small" icon="el-icon-time"-->
    <!--                             @click="historyEvent(scope.row)">历史版本</el-button>-->
    <!--                  &lt;!&ndash;                  <el-button type="text"  icon="el-icon-tickets" size="small" @click="materialShowStatus(scope.row)">材料模板</el-button>&ndash;&gt;-->
    <!--                  &lt;!&ndash;                  <el-button type="text"  icon="el-icon-postcard" size="small" @click="licenseMaintain(scope.row)">证照维护</el-button>&ndash;&gt;-->
    <!--                  <el-button type="text" icon="el-icon-set-up" size="small"-->
    <!--                             @click="itemLevel(scope.row)">业务环节</el-button>-->
    <!--                  &lt;!&ndash;                  <el-button v-if="scope.row.isSendsms=='0' " type="text" size="small" @click="isSendsms(scope.row,'1')">启用短信</el-button>-->
    <!--                                    <el-button v-if="scope.row.isSendsms=='1' " type="text" size="small" @click="isSendsms(scope.row,'0')">禁用短信</el-button>&ndash;&gt;-->
    <!--                  <el-button type="text" icon="el-icon-tickets" size="small"-->
    <!--                             @click="baseConfigure(scope.row)">事项基本配置</el-button>-->
    <!--                  <el-button type="text" icon="el-icon-tickets" size="small" @click="shiXiangVisible1(scope.row,val=1)"-->
    <!--                             :disabled="scope.row.itemLevel == '6' || scope.row.itemLevel == '7' ?  false : true">部门对接管理</el-button>-->
    <!--                </template>-->
    <!--                <template slot-scope="scope"-->
    <!--                          slot="promiseDay">-->
    <!--                    {{ scope.row.promiseDay + '工作日' }}-->
    <!--                </template>-->
    <!--            </avue-crud>-->
    <!--        </span>-->
    <el-drawer :title="itemTitle" size="calc(100% - 240px)"
               height="50%"
               append-to-body="true"
               :before-close="handleClose"
               :close-on-click-modal="false"
               :visible.sync="processVisible">
      <div style="padding: 40px;height: 100%" v-if="processVisible">
        <!--        <step-line :stepnow="stepnow" :stepmsg="stepmsg"></step-line>-->
        <div class="step_box_card">
          <!--          <div v-show="stepnow === 1">-->
          <!--            <div class="zz_card_box">-->
          <!--              <div class="card_left">-->
          <!--                <ul v-if="jsonArrayData.length !== 0">-->
          <!--                  <li class="card_item" @click="changeChooseLeft(item)" :class="{'choose': item.isChoose}"-->
          <!--                      v-for="item in jsonArrayData" :key="item.CERTYPE_DTL_ID">-->
          <!--                    <div class="icon">-->
          <!--                      <img src="/img/matter.png">-->
          <!--                    </div>-->
          <!--                    <avue-text-ellipsis :text="item.CERTYPE_DTL_NAME" :height="50" use-tooltip placement="top">-->
          <!--                      <small slot="more">...</small>-->
          <!--                    </avue-text-ellipsis>-->
          <!--                  </li>-->
          <!--                </ul>-->
          <!--                <div class="img_box" v-else>-->
          <!--                  <img src="/img/noMatter.png">-->
          <!--                  <p>未查询到此事项有可维护证照</p>-->
          <!--                </div>-->
          <!--              </div>-->
          <!--              <div class="card_right">-->
          <!--                <ul v-if="servvCertificate.length !== 0">-->
          <!--                  <li class="card_item choose" :class="item.operationType + '_choose'"-->
          <!--                      @click="changeChooseRight(item, index)"-->
          <!--                      v-for="(item,index) in servvCertificate">-->
          <!--                    <div class="icon">-->
          <!--                      <img src="/img/matter.png">-->
          <!--                    </div>-->
          <!--                    <avue-text-ellipsis :text="item.certypeDtlName" :height="50" use-tooltip placement="top">-->
          <!--                      <small slot="more">...</small>-->
          <!--                    </avue-text-ellipsis>-->
          <!--                  </li>-->
          <!--                </ul>-->
          <!--                <div class="img_box" v-else>-->
          <!--                  <img src="/img/noMatter.png">-->
          <!--                  <p>尚未维护证照</p>-->
          <!--                </div>-->
          <!--              </div>-->
          <!--              <div class="card_type" style="width: 30%; height: 100%;overflow-y:auto"-->
          <!--                   v-if="!validatenull(servvCertificate)">-->
          <!--                <el-table class="avue-crud"-->
          <!--                          :data="servvCertificate"-->
          <!--                          border-->
          <!--                          style="width: 100%"-->
          <!--                          size="small">-->
          <!--                  <el-table-column label="证照名称"-->
          <!--                                   prop="certypeDtlName"-->
          <!--                                   align="center"-->
          <!--                                   :show-overflow-tooltip="true"-->
          <!--                                   header-align="center">-->
          <!--                  </el-table-column>-->
          <!--                  <el-table-column label="操作类型"-->
          <!--                                   prop="operationType"-->
          <!--                                   align="center"-->
          <!--                                   width="125"-->
          <!--                                   header-align="center">-->
          <!--                    <template #default="{row, $index}">-->
          <!--                      <el-select v-model="row.operationType" placeholder="操作类型" clearable>-->
          <!--                        <el-option label="新增" value="add"></el-option>-->
          <!--                        <el-option label="变更" value="change"></el-option>-->
          <!--                        <el-option label="延续" value="continue"></el-option>-->
          <!--                        <el-option label="注销" value="cancel"></el-option>-->
          <!--                        <el-option label="废止" value="abolish"></el-option>-->
          <!--                      </el-select>-->
          <!--                    </template>-->
          <!--                  </el-table-column>-->
          <!--                </el-table>-->
          <!--              </div>-->
          <!--            </div>-->
          <!--            <div class="zz_btn_box">-->
          <!--              <el-button type="danger" v-if="servvCertificate.length > 0" @click="handleRemoveAll" plain size="small"-->
          <!--                         :loading="licenseLoading">-->
          <!--                置空证照目录-->
          <!--              </el-button>-->
          <!--              <el-button type="primary" @click="handleSave" :loading="licenseLoading" v-if="servvCertificate.length > 0"-->
          <!--                         size="small">保存-->
          <!--              </el-button>-->
          <!--            </div>-->
          <!--            &lt;!&ndash;            <avue-form :option="licenseOption"&ndash;&gt;-->
          <!--            &lt;!&ndash;                       v-model="licenseForm"&ndash;&gt;-->
          <!--            &lt;!&ndash;                       ref="licenseForm"&ndash;&gt;-->
          <!--            &lt;!&ndash;                       @submit="handleSure">&ndash;&gt;-->
          <!--            &lt;!&ndash;              <template slot="menuForm">&ndash;&gt;-->
          <!--            &lt;!&ndash;                <el-button type="primary"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           size="large"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           class="btn-sub"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           :loading="lincenseSaveLoading"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           v-show="lincenseSaveBtn"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           @click.stop="lincenseSave">保存&ndash;&gt;-->
          <!--            &lt;!&ndash;                </el-button>&ndash;&gt;-->
          <!--            &lt;!&ndash;                <el-button type="danger"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           size="large"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           class="btn-sub"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           v-show="lincenseDeleteBtn"&ndash;&gt;-->
          <!--            &lt;!&ndash;                           @click.stop="lincenseDelete">置空证照目录&ndash;&gt;-->
          <!--            &lt;!&ndash;                </el-button>&ndash;&gt;-->
          <!--            &lt;!&ndash;              </template>&ndash;&gt;-->
          <!--            &lt;!&ndash;            </avue-form>&ndash;&gt;-->

          <!--          </div>-->
          <div v-show="stepnow === 1">
            <avue-tabs :option="linkOption" @change="handleLinkChange"></avue-tabs>
            <span v-if="linkTabType.prop === 'linkConfiguration'">
            <avue-form :option="processOption" v-model="processForm" ref="processForm" @submit="handleProcess">
              <template slot="processConfiguration">
                <el-table class="avue-crud"
                          :data="userData"
                          border
                          size="small">
                  <el-table-column align="center"
                                   header-align="center"
                                   width="80">
                                        <template #header>
                                          <el-button circle
                                                     type="primary"
                                                     size="mini"
                                                     icon="el-icon-plus"
                                                     @click="userDataPush"></el-button>
                                        </template>
                    <template #default="{$index}">
                      <el-button circle
                                 type="danger"
                                 size="mini"
                                 icon="el-icon-delete"
                                 @click="userDataSplice($index)"></el-button>
                    </template>
                  </el-table-column>
                  <el-table-column label="环节名称"
                                   prop="linkName"
                                   align="center"
                                   header-align="center">
                    <template #default="{row, $index}">
                      <!--                <el-input v-model="row.linkName" size="small" placeholder="请输入环节名称"></el-input>-->
                      <!--                <el-autocomplete v-model="row.linkName"-->
                      <!--                                 placeholder="请输入环节名称"-->
                      <!--                                 :trigger-on-focus="false"-->
                      <!--                                 :fetch-suggestions="linkListFetch"-->
                      <!--                                 @select="linkSelect($event, row, $index)">-->
                      <!--                </el-autocomplete>-->
                      <!--                      <el-select v-model="row.linkName" filterable placeholder="请输入环节名称" disabled>-->
                      <!--                        <el-option v-for="item in linkList"-->
                      <!--                                   :key="item.value"-->
                      <!--                                   :label="item.value"-->
                      <!--                                   :value="item.value">-->
                      <!--                        </el-option>-->
                      <!--                      </el-select>-->
                      <el-input v-model="row.linkName" placeholder="请输入环节名称"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="环节办理时限（天）"
                                   prop="timeLimit"
                                   align="center"
                                   header-align="center">
                    <template #default="{row, $index}">
                      <el-input-number :min="0"
                                       controls-position="right"
                                       v-model="row.timeLimit"
                                       size="medium"
                                       @input="timeInput(row.timeLimit, $index)"
                                       @keydown.native="channelInputLimit"
                                       placeholder="请输入环节办理时限"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column label="排序（顺序）"
                                   prop="linkSort"
                                   align="center"
                                   header-align="center">
                    <template #default="{row, $index}">
                      <el-input-number :min="1"
                                       controls-position="right"
                                       v-model="row.linkSort"
                                       size="medium"
                                       @input="sortInput(row.linkSort, $index)"
                                       placeholder="请输入排序（顺序）"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column label="人员"
                                   prop="text"
                                   align="center"
                                   header-align="center">
                    <template #default="{row, $index}">
                      <el-input v-model="row.text"
                                size="small"
                                placeholder="请选择人员"
                                readonly
                                @click.native="handleSelect($index, 'user-select')">
                        <template #append>
                          <el-button icon="el-icon-plus"></el-button>
                        </template>
                      </el-input>
                    </template>
                  </el-table-column>
                </el-table>
              </template>
              <template slot="menuForm">
                <el-button type="primary"
                           size="large"
                           class="btn-sub"
                           :loading="linkLoading"
                           @click="linkSave">保存
              </el-button>
              <el-button type="danger"
                         size="large"
                         class="btn-sub"
                         v-show="linkDeleteShow"
                         :loading="linkLoading"
                         @click="linkDelete">置空环节
              </el-button>
              </template>
              <template slot-scope="{disabled,size}" slot="designFlowBtn" v-if="rowData.itemLevel == '3'">
                  <div>
                    <el-button :size="size" type="primary" @click="editFlow">编辑流程</el-button>
                    <span>点击下载编辑流程<a
                      href="http://59.219.204.45:10070/vingsoft/upload/20220717/5e0af4787ae6b0ab9b9da15260f12d06.docx">操作文档</a></span>
                </div>
              </template>
            </avue-form>
            <user-select ref="user-select"
                         check-type="checkbox"
                         :user-url="userUrl"
                         :custom-option="customOption"
                         :default-checked="defaultChecked"
                         @onConfirm="handleSelectConfirm">
            </user-select>
            </span>
            <span v-else-if="linkTabType.prop === 'linkVersion'">
              <avue-crud :option="optionActivity"
                         :table-loading="loadingActivity"
                         :data="dataActivity"
                         ref="crudActivity"
                         v-model="formActivity"
                         @current-change="currentActivityChange"
                         @size-change="sizeActivityChange"
                         :page.sync="pageActivity"
                         @on-load="onLoadActivity">
                <template slot-scope="scope" slot="menu">
                  <el-button
                    type="text"
                    icon="el-icon-circle-plus-outline"
                    size="small"
                    @click.stop="linkHistory(scope.row)">环节信息
                  </el-button>
                </template>
              </avue-crud>
              <el-dialog title="环节信息"
                         append-to-body
                         :visible.sync="linkBox"
                         width="70%">
                <avue-crud :option="optionVersion"
                           :table-loading="loadingVersion"
                           :data="dataVersion"
                           ref="crudActivity"
                           v-model="formVersion"
                           :page.sync="pageVersion"
                           @on-load="onLoadVersion">
                </avue-crud>
              </el-dialog>
            </span>
          </div>
        </div>
        <!--        <div class="foot_button_group">-->
        <!--          <el-button v-show="stepnow > 1" @click="ToPorp()">上一步</el-button>-->
        <!--          <el-button type="primary" :disabled="!NextStep" v-show="stepnow < steps" @click="ToNext()"-->
        <!--                     :loading="loading === true">下一步-->
        <!--          </el-button>-->
        <!--          &lt;!&ndash; <el-button type="primary" v-show="stepnow === steps" @click="Close()">关闭</el-button>&ndash;&gt;-->
        <!--        </div>-->
      </div>
    </el-drawer>

    <el-drawer
      center="true"
      size="calc(100% - 240px)"
      title="新增"
      append-to-body
      :visible.sync="drawer01"
      :before-close="handleClose">
      <el-form label-width="140px" :model="subForm" size="medium" ref="subForm" :rules="rules">
        <el-form-item label="id" hidden>
          <el-input type="input" v-model="subForm.id"></el-input>
        </el-form-item>
        <el-form-item label="事项来源" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.className"></el-input>
        </el-form-item>
        <el-form-item label="系统名称" style="margin-top: 20px">
          <el-select placeholder="请选择" v-model="subForm.deptinterId">
            <el-option
              v-for="item in options11"
              :key="item.id"
              :label="item.systemName"
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="区划编码" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.areaCode"></el-input>
        </el-form-item>
        <el-form-item label="区划名称" style="margin-top: 20px">
          <el-input disabled v-model="subForm.areaName">
          </el-input>
        </el-form-item>
        <el-form-item label="部门编码" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.deptCode"></el-input>
        </el-form-item>
        <el-form-item label="部门名称" style="margin-top: 20px">
          <el-input type="select" disabled v-model="subForm.deptName"></el-input>
        </el-form-item>
        <el-form-item label="事项唯一编码" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.itemId"></el-input>
        </el-form-item>
        <el-form-item label="事项名称" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.servName"></el-input>
        </el-form-item>
        <el-form-item label="备注" style="margin-top: 20px">
          <el-input type="textarea" v-model="subForm.remarks"></el-input>
        </el-form-item>

        <el-button type="primary"
                   size="large"
                   class="btn-sub" style="margin-left: 750px;margin-top: 50px" @click="QX01">取消
        </el-button>
        <el-button type="primary"
                   size="large"
                   class="btn-sub" style="margin-left: 50px" @click="TJ01">提交
        </el-button>

      </el-form>
    </el-drawer>
    <el-drawer
      title="流程编辑"
      center="true"
      append-to-body
      size="calc(100% - 240px)"
      :visible.sync="formShow"
      :before-close="flowClose">
      <index-form @getSubmitArg="getSubmitArg($event)" v-if="formShow" :serviceItem="rowData"
                  :servTableType="type.prop==='task_general_basic' ? '1' : '2'"></index-form>
    </el-drawer>
    <el-drawer
      title="编辑"
      center="true"
      append-to-body
      size="calc(100% - 240px)"
      :visible.sync="drawer02"
      :before-close="handleClose">
      <el-form label-width="140px" :model="subForm" size="medium" ref="subForm" :rules="rules">
        <el-form-item label="id" hidden>
          <el-input type="input" v-model="subForm.id"></el-input>
        </el-form-item>
        <el-form-item label="事项来源" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.className"></el-input>
        </el-form-item>
        <el-form-item label="系统名称" style="margin-top: 20px">
          <el-select placeholder="请选择" v-model="subForm.deptinterId">
            <el-option
              v-for="item in options12"
              :key="item.id"
              :label="item.systemName"
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="区划编码" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.areaCode"></el-input>
        </el-form-item>
        <el-form-item label="区划名称" style="margin-top: 20px">
          <el-input disabled v-model="subForm.areaName">
          </el-input>
        </el-form-item>
        <el-form-item label="部门编码" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.deptCode"></el-input>
        </el-form-item>
        <el-form-item label="部门名称" style="margin-top: 20px">
          <el-input type="input" disabled class="deptName" v-model="subForm.deptName"></el-input>
        </el-form-item>
        <el-form-item label="事项唯一编码" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.itemId"></el-input>
        </el-form-item>
        <el-form-item label="事项名称" style="margin-top: 20px">
          <el-input type="input" disabled v-model="subForm.servName"></el-input>
        </el-form-item>
        <el-form-item label="备注" style="margin-top: 20px">
          <el-input type="textarea" v-model="subForm.remarks"></el-input>
          <!--          @blur="subForm.backContent=$event.target.value.trim()"-->
        </el-form-item>

        <el-button type="primary"
                   size="large"
                   class="btn-sub" style="margin-left: 750px;margin-top: 50px" @click="QX02">取消
        </el-button>
        <el-button type="primary"
                   size="large"
                   class="btn-sub" style="margin-left: 50px" @click="TJ02">提交
        </el-button>

      </el-form>
    </el-drawer>

    <!-- 办事指南   -->
    <el-drawer center="true"
               size="calc(100% - 240px)"
               title="办事指南"
               append-to-body
               :visible.sync="guideShow">
      <serviceGuide :serviceItem="serviceItem"
                    v-if="guideShow"
                    :declare="declare">
      </serviceGuide>
    </el-drawer>
    <!-- 事项历史版本   -->
    <el-drawer center="true"
               size="calc(100% - 240px)"
               :title="eventHistoryList"
               append-to-body
               :visible.sync="enentHistoryShow">
      <event-inquiry-history :serviceHistory="serviceHistory"
                             v-if="enentHistoryShow">
      </event-inquiry-history>
    </el-drawer>
    <!-- 材料模板   -->
    <el-drawer center="true"
               size="calc(100% - 240px)"
               :title="materialTitle"
               append-to-body
               :visible.sync="materialShow">
      <service-guide-material :serviceItem="serviceItem"
                              v-if="materialShow">
      </service-guide-material>
    </el-drawer>
    <!-- 证照应用   -->
    <!--    <el-dialog title="证照应用" width="40%"-->
    <!--               height="40%"-->
    <!--               append-to-body="true"-->
    <!--               :visible.sync="licenseVisible">-->
    <!--      -->
    <!--    </el-dialog>-->
    <el-dialog title="流程环节信息导入"
               append-to-body
               :visible.sync="excelBox"
               width="555px">
      <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"></avue-form>
    </el-dialog>
    <el-dialog title="导入失败数据" append-to-body :visible.sync="errorBox" width="1000px">
      <el-table :data="errorData">
        <el-table-column property="linkModelName" label="事项名称"></el-table-column>
        <el-table-column property="linkDeptName" label="部门名称"></el-table-column>
        <el-table-column property="linkProcessName" label="环节" width="100px"></el-table-column>
        <el-table-column property="linkUserName" label="办理人员" width="200px"></el-table-column>
        <el-table-column property="linkActivityDuty" label="描述"></el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog
      title="事项基本配置"
      :visible.sync="baseConfigVisible"
      :close-on-click-modal="false"
      append-to-body
      :before-close="baseConfigClose"
      width="60%"
      v-if="baseConfigVisible"
      :destroy-on-close="true">
      <avue-form :option="servExtendOption"
                 v-model="servExtendForm">
      </avue-form>

      <el-row>
        <el-col :span="12" :offset="10">
          <el-button @click="QXDX" :loading="servExtendLoading">取消</el-button>
          <el-button type="primary" @click="TJDX" :loading="servExtendLoading">提交</el-button>
        </el-col>
      </el-row>
    </el-dialog>
    <el-drawer
      title="事项详情"
      :visible.sync="viewVisible"
      :append-to-body="true"
      size="70%"
      :destroy-on-close="true">
      <avue-form :option="optionForm" v-model="obj">
        <template slot-scope="scope" slot="materialInfo">
          <div v-if="materialInfoData&&materialInfoData.length>0">
            <material-info
              :material-info="materialInfoData"></material-info>
          </div>
          <div v-else>暂无材料</div>
        </template>
        <template slot-scope="scope" slot="process">
          <div v-if="processData&&processData.length>0">
            <handling-process :process-data="processData"></handling-process>
          </div>
          <div v-else>暂无材料</div>
        </template>
        <template slot="anticipateDay">
          <div v-if="obj.anticipateDay!==''">{{ obj.anticipateDay + '个工作日' }}</div>
        </template>
        <template slot="promiseDay">
          <div v-if="obj.promiseDay!==''">{{ obj.promiseDay + '个工作日' }}</div>
        </template>
        <template slot="handProcessHeader" slot-scope="{column}">
          <div style="width: 100%;height: 100%;display: flex;justify-content: space-between;align-items: center">
            <div style="display: flex;align-items: center">
              <i class="el-icon-user-solid" style="font-size: 20px;margin-right: 10px"></i>
              <div style="font-size: 16px; margin-right: 20px">{{ column.label }}</div>
              <div class="links" v-if="obj.flowChart&&obj.flowChart!==''">
                <el-link type="primary" style="font-size: 16px" @click="openFlow(obj.flowChart)">点击查看办理流程图
                </el-link>
                <i class="el-icon-arrow-right" style="color:#146ad1;font-size: 14px;"></i>
              </div>
            </div>
          </div>
        </template>
      </avue-form>
    </el-drawer>
  </basic-container>
</template>
<script>
import {
  getList,
  getListInfo,
  getChildListInfo,
  taskList,
  taskActivityConfig,
  getDetailById,
  deleteActivityConfig,
  saveIsSendsms
} from "@/api/acceptance/serviceItem";
import {optionItem} from "@/option/acceptance/serviceItem";
import {optionPublicItem} from "@/option/acceptance/serviceItem";
import {servExtendOption} from "@/option/ywsp/serv_extend";
import {fitletaskName, fitleTaskCodeOrTaskHandleItem} from "@/option/acceptance/caseBaseInfo";
import UserSelect from '@/views/eventManagement/components/user-select.vue';
import {mapGetters} from "vuex";
import {
  remove,
  buildFlow,
  saveActivityLinkName,
  getActivityLinkName,
  getDeploymentListByKey,
  deleteActivity,
  selectActivityPage,
  selectActivityVersionPage
} from "@/api/plugin/workflow/deployment";
import {removeByModelKey, getDeploymentById} from "@/api/plugin/workflow/model";
import {getDictionary} from "@/api/system/dictbiz";
import serviceGuide from "@/views/eventManagement/service_guide";
import eventInquiryHistory from "@/views/eventManagement/eventInquiryHistory";
import serviceGuideMaterial from "@/views/eventManagement/service_guide_material";
import {
  getLicneseTypeNameData,
  getTaskExtend,
  getLicneseTypeNameJsonArray,
  getTaskBase
} from "@/api/acceptance/caseinfo";
import StepLine from "../../components/web/stepLine";
import {getActivityList} from "@/api/acceptance/taskGeneralActivity";
import {validatenull} from "@/util/validate";
import {addInter, selectAreaName, selectId, selectItemId, update, selectupdate} from "@/api/ywsp/deptInterServ";
import {saveI, updateI, selectitemId, submit as submitServExtend} from "@/api/ywsp/ServExtend";
import {getServCertificateByItem, save} from '@/api/acceptance/servcertificate'
import indexForm from '@/views/plugin/workflow/design/indexForm'
import {filterTreeByKeyWord, getRegionList, regionPermissionLazy} from "@/api/system/region";
import {getPage, getTaskDetail} from "@/api/eventManagement/eventInquiry";
import HandlingProcess from "@/views/eventManagement/components/handlingProcess.vue";
import MaterialInfo from "@/views/eventManagement/components/materialInfo.vue";

export default {
  name: "eventLink",
  components: {
    MaterialInfo,
    HandlingProcess,
    StepLine, UserSelect, serviceGuide, eventInquiryHistory, serviceGuideMaterial, indexForm
  },
  data() {
    const validateProcessName = (rule, value, callback) => {
      let rules1 = /^\S*$/;
      if (value == '' || value == null) {
        callback(new Error('请输入流程名称'));
      } else if (!rules1.test(value)) {
        callback(new Error("输入内容不能有空格"))
      } else if (value != '' || value != null) {
        if (this.deployMentName.includes(value)) {
          callback(new Error('流程名称已重复，请重新输入'));
        } else {
          callback();
        }
      }
    };
    const validateProcessId = (rule, value, callback) => {
      let rules1 = /^\S*$/;
      let rules2 = /^[A-Za-z-_]*(\s[A-Za-z-_]*)*$/;
      if (value == '' || value == null) {
        callback(new Error('请输入流程标识'));
      } else if (!rules1.test(value)) {
        callback(new Error("输入内容不能有空格"))
      } else if (value != '' || value != null) {
        if (this.deployMentKey.includes(value)) {
          callback(new Error('流程标识已重复，请重新输入'));
        } else if (!rules2.test(value)) {
          callback(new Error('流程标识请输入英文（参照历史流程标识格式填写）'));
        } else {
          callback();
        }
      }
    }
    return {
      subForm: {
        id: "",
        deptinterId: "",
        areaName: "",
        areaCode: "",
        deptName: "",
        deptCode: "",
        servName: "",
        remarks: "",
        className: "",
      },
      servExtendOption: servExtendOption,
      servExtendForm: {},
      servExtendLoading: false,
      viewVisible: false,
      options11: [],
      options12: [],
      obj: {},
      optionForm: {
        detail: true,
        labelWidth: 180,
        submitBtn: false,
        emptyBtn: false,
        group: [
          {
            label: '基本信息',
            prop: 'baseInfo',
            icon: 'el-icon-user-solid',
            column: [
              {
                label: "事项类型",
                prop: "taskType",
                type: 'select',
                dicUrl: '/api/blade-system/dict-biz/dictionary?code=event_type',
                props: {
                  label: "dictValue",
                  value: "dictKey"
                },
              },
              {
                label: "基本编码",
                prop: "catalogCode",
              },
              {
                label: "办理项编码",
                prop: "ywcode",
                hide: true,
              },
              {
                label: "行使层级",
                prop: "useLevel",
                hide: true,
                type: 'select',
                dicUrl: '/api/blade-system/dict-biz/dictionary?code=use_level',
                props: {
                  label: "dictValue",
                  value: "dictKey"
                },
              },
              {
                label: "办理形式",
                prop: "handleType",
                hide: true,
                type: 'select',
                multiple: true,
                dicUrl: '/api/blade-system/dict-biz/dictionary?code=handle_type',
                props: {
                  label: "dictValue",
                  value: "dictKey"
                },
              },
              {
                label: "到办事现场次数",
                prop: "limitSceneNum",
                hide: true,
              },
              {
                label: "特别程序",
                prop: "specialProgram",
                span: 24,
                hide: true,
              },
            ]
          },
          {
            label: '部门信息',
            prop: 'jbxx',
            icon: 'el-icon-s-custom',
            column: [
              {
                label: "实施主体（部门标识）",
                prop: "deptName",
                hide: true,
              },
              {
                label: "实施主体编码",
                prop: "deptCode",
                hide: true,
              },
              {
                label: "实施主体性质",
                prop: "deptType",
                type: 'select',
                dicUrl: '/api/blade-system/dict-biz/dictionary?code=dept_type',
                props: {
                  label: "dictValue",
                  value: "dictKey"
                },
              },
              {
                label: "权力来源",
                prop: "itemSource",
                type: 'select',
                dicUrl: '/api/blade-system/dict-biz/dictionary?code=item_source',
                props: {
                  label: "dictValue",
                  value: "dictKey"
                },
              },

            ]
          },
          {
            label: '窗口办理',
            prop: 'jbxx',
            icon: 'el-icon-s-platform',
            column: [
              {
                label: "办理地点",
                prop: "transactAddr",
                type: 'textarea',
                hide: true,
                span: 24,
              },
              {
                label: "办理时间",
                prop: "transactTime",
                hide: true,
                span: 24,
              },

            ]
          },
          {
            label: '受理标准',
            prop: 'jbxx',
            icon: 'el-icon-s-management',
            column: [
              {
                label: "服务对象",
                prop: "serveType",
                multiple: true,
                hide: true,
                span: 24,
                type: 'select',
                dicUrl: '/api/blade-system/dict-biz/dictionary?code=serve_type',
                props: {
                  label: "dictValue",
                  value: "dictKey"
                },
              },
              {
                label: "受理条件",
                prop: "acceptCondition",
                type: 'textarea',
                hide: true,
                span: 24,
              },
            ]
          },
          {
            label: '办理材料',
            prop: 'materials',
            icon: 'el-icon-upload',
            column: [
              {
                label: '',
                prop: 'materialInfo',
                span: 24,
                labelWidth: 0,
              }
            ]
          },
          {
            label: '办理流程',
            prop: 'handProcess',
            icon: 'el-icon-s-management',
            column: [
              {
                label: '',
                prop: 'process',
                labelWidth: 0,
                span: 24
              }
            ]
          },
          {
            label: '办理时限',
            prop: 'jbxx',
            icon: 'el-icon-s-opportunity',
            column: [
              // {
              //   label: "办件类型",
              //   prop: "projectType",
              //   type: 'select',
              //   multiple: true,
              //   dicUrl: '/api/blade-system/dict-biz/dictionary?code=apply_type',
              //   props: {
              //     label: "dictValue",
              //     value: "dictKey"
              //   },
              //   hide: true,
              //   span: 24,
              // },
              {
                label: "法定办结时限",
                prop: "anticipateDay",
                hide: true,
              },
              {
                label: "承诺办结时限",
                prop: "promiseDay",
                hide: true,
              },
              {
                label: "法定办结时限说明",
                prop: "anticipateDayExplain",
                type: 'textarea',
                hide: true,
              },
              {
                label: "承诺办结时限说明",
                prop: "promiseDayExplain",
                type: 'textarea',
                hide: true,
              },
            ]
          },
          {
            label: '收费情况',
            prop: 'jbxx',
            icon: 'el-icon-s-ticket',
            column: [
              {
                label: "是否收费",
                prop: "isFee",
                hide: true,
                type: 'select',
                span: 24,
                dicUrl: "/api/blade-system/dict-biz/dictionary?code=yes_no",
                props: {
                  label: "dictValue",
                  value: "dictKey"
                },
              },
              {
                label: "收费依据",
                prop: "chargeByLaw",
                span: 24,
                hide: true,
                type: "textarea"
              },

            ]
          },
          {
            label: '法律依据',
            prop: 'jbxx',
            icon: 'el-icon-s-order',
            column: [
              {
                label: "设定依据",
                prop: "byLaw",
                hide: true,
                type: "textarea",
                span: 24
              },
              {
                label: "增补依据",
                prop: "byLawExtend",
                hide: true,
                type: "textarea",
                span: 24
              },
            ]
          },
          {
            label: '咨询投诉',
            prop: 'jbxx',
            icon: 'el-icon-s-marketing',
            column: [
              {
                label: "咨询方式",
                prop: "linkWay",
                hide: true,
                span: 24
              },
              {
                label: "监督投诉方式",
                prop: "superviseWay",
                hide: true,
                type: "textarea",
                span: 24
              },
            ]
          },
        ],
      },
      baseConfigVisible: false,
      shiXiang: false,
      errorBox: false,
      drawer01: false,
      drawer02: false,
      errorData: [],
      excelBox: false,
      excelForm: {},
      excelOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '模板上传',
            prop: 'excelFile',
            type: 'upload',
            drag: true,
            loadText: '模板上传中，请稍等',
            span: 24,
            propsHttp: {
              res: 'data'
            },
            tip: '请上传 .xls 标准格式文件',
            action: "/api/blade-workflow/build/activity/import_excel"
          }
        ]
      },
      type: {},
      rowData: {},
      extendType: '',
      tabOption: {
        column: [{
          icon: 'el-icon-info',
          label: '依申请类',
          prop: 'task_general_basic',
        }, {
          icon: 'el-icon-warning',
          label: '公共服务类',
          prop: 'task_public_basic',
        }]
      },
      loading: false,
      form: {},
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      data: [],
      materialInfoData: [],
      processData: [],
      query: {},
      option: optionItem,
      option2: optionPublicItem,
      serviceItem: {},
      processVisible: false,
      processOption: {
        submitBtn: false,
        emptyBtn: false,
        labelWidth: 100,
        column: [
          {
            label: "",
            prop: "designFlowBtn",
            formslot: true,
          },
          {
            label: '流程名称',
            prop: 'processName',
            span: 12,
            disabled: true,
            display: false,
            rules: [
              {
                required: true,
                validator: validateProcessName,
                trigger: "click"
              }
            ]
          },
          {
            label: '流程标识',
            prop: 'processId',
            span: 12,
            display: false,
            disabled: true,
            rules: [
              {
                required: true,
                validator: validateProcessId,
                trigger: "click"
              }
            ]
          },
          {
            label: '环节配置',
            prop: 'processConfiguration',
            formslot: true,
            display: true,
            //type: 'dynamic',
            span: 24,
            // children: {
            //   align: 'center',
            //   headerAlign: 'center',
            //   rowAdd:(done)=>{
            //     done();
            //   },
            //   rowDel:(row,done)=>{
            //     done();
            //   },
            //   column:[
            //     {
            //       label: '环节名称',
            //       prop: 'linkName'
            //     },
            //     {
            //       label: '姓名',
            //       prop: 'value',
            //     },
            //   ]
            // }
          }
        ]
      },
      shiXiangVisible: false,
      processForm: {},
      selectIndex: 0,
      defaultChecked: '',
      userData: [
        /*{
          "linkName":"受理"
        },
        {
          "linkName":"办结"
        }*/
      ],
      init: false,
      userOption: {
        userUrl: '/api/blade-user/search/user',
        roleUrl: '/api/blade-system/search/role',
        deptUrl: '/api/blade-system/search/dept',
        postUrl: '/api/blade-system/search/post',
      },
      visible: false,
      deployMentName: [],
      deployMentKey: [],
      linkType: 'add',
      guideShow: false,
      eventHistoryList: '',
      enentHistoryShow: false,
      serviceHistory: {},
      linkList: [],
      materialShow: false,
      // licenseVisible: false,
      licenseOption: {
        labelWidth: 140,
        submitBtn: false,
        emptyBtn: false,
        submitText: '保存',
        column: [
          {
            label: 'taskGuid',
            prop: 'taskGuid',
            display: false
          },
          {
            label: '事项名称',
            prop: 'taskName',
            span: 24,
            disabled: true,
            rules: [
              {
                required: true,
                message: '请输入事项名称'
              }
            ]
          },
          {
            label: '证照目录',
            prop: 'licenseTypeName',
            type: 'select',
            span: 24,
            filterable: true,
            dicData: [
              // {
              //   label:'证1',
              //   value:1
              // },
              // {
              //   label: '证2',
              //   value: 2
              // }
            ],
            rules: [
              {
                required: true,
                message: '请选择证照目录'
              }
            ],
            change: ({value}) => {
              if (value != this.licenseForm.licenseTypeName) {
                this.lincenseSaveBtn = true;
                this.lincenseDeleteBtn = true;
              }
            },
          }
        ]
      },
      licenseForm: {},
      materialTitle: '',
      linkOption: {
        column: [
          {
            icon: 'el-icon-setting',
            label: '环节配置',
            prop: 'linkConfiguration'
          },
          {
            icon: 'el-icon-info',
            label: '环节版本',
            prop: 'linkVersion'
          }
        ]
      },
      linkTabType: {},
      itemTitle: '',
      stepnow: 1,
      stepmsg: ['证照维护', '事项环节人员配置'],
      NextStep: true,
      steps: 2,//总步骤
      optionActivity: {
        refreshBtn: false,
        columnBtn: false,
        searchShowBtn: false,
        calcHeight: 30,
        tip: false,
        border: true,
        selection: false,
        dialogType: 'drawer',
        addBtn: false,
        editBtn: false,
        delBtn: false,
        align: 'center',
        index: true,
        indexLabel: '序号',
        searchMenuPosition: "left",
        searchLabelWidth: 120,
        searchMenuSpan: 6,
        column: [
          {
            label: '流程名称',
            prop: 'linkModelName',
          },
          {
            label: '版本',
            prop: 'linkVersion',
            width: 300
          },
          {
            label: '创建时间',
            prop: 'createTime',
            width: 400
          },
        ]
      },
      dataActivity: [],
      formActivity: {},
      pageActivity: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      pageVersion: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      linkBox: false,
      optionVersion: {
        menu: false,
        refreshBtn: false,
        columnBtn: false,
        searchShowBtn: false,
        calcHeight: 30,
        tip: false,
        border: true,
        selection: false,
        dialogType: 'drawer',
        addBtn: false,
        editBtn: false,
        delBtn: false,
        align: 'center',
        index: true,
        indexLabel: '序号',
        searchMenuPosition: "left",
        searchLabelWidth: 120,
        searchMenuSpan: 6,
        column: [
          {
            label: '环节名称',
            prop: 'linkProcessName',
          },
          {
            label: '环节办理时限',
            prop: 'linkHandleTimeLimit',
            width: 300
          },
          {
            label: '环节执行人员',
            prop: 'linkUserName',
            width: 300
          },
          {
            label: '创建时间',
            prop: 'createTime',
          },
          {
            label: '创建人',
            prop: 'createUser',
          },
        ]
      },
      dataVersion: [],
      formVersion: {},
      linkItemId: '',
      selectareaNames: '',
      linkVersion: '',
      loadingVersion: false,
      loadingActivity: false,
      activityData: [],
      itemRandomLetter: '',
      jsonArrayData: [],
      lincenseSaveBtn: true,
      lincenseDeleteBtn: true,
      licenseFormShow: true,
      lincenseSaveLoading: false,
      linkDeleteShow: false,
      servvCertificate: [],
      formShow: false,


      //部门
      deptTreeData: [],
      isAsync: false,
      zIndex: 99999,
      defaultExpandLevel: 1,
      searchQuery: null,
      search: {
        startDate: null,
        endDate: null,
        servDeptCode: null,
      },
      licenseLoading: false,
      linkLoading: false
    };
  },
  inject: ['reload'],
  created() {
    // this.initDeptTree();
    this.createRandomLetter();
    this.type = this.tabOption.column[0];
    this.extendType = "task_general_extend";
    // selectId().then(res => {
    //   let data = res.data.data;
    //   this.options11 = data;
    //   this.options12 = data;
    // });
    //给时间当前日期前7天
    /*let date = new Date();
    date.setDate(date.getDate() - 7);
    let mon = null;
    let day = null;
    if ((date.getMonth() + 1) < 10) {
      mon = "0" + (date.getMonth() + 1);
    }else {
      mon =  (date.getMonth() + 1);
    }
    if (date.getDate() < 10) {
      day = "0" + date.getDate();
    }else {
      day = date.getDate();
    }
    let oldDate = date.getFullYear() + '-' + mon + '-' + day;



    let date2 = new Date();
    let mon2 = null;
    let day2 = null;
    if ((date2.getMonth() + 1) < 10) {
      mon2 = "0" + (date2.getMonth() + 1);
    }else {
      mon2 =  (date.getMonth() + 1);
    }
    if (date2.getDate() < 10) {
      day2 = "0" + date2.getDate();
    }else {
      day2 = date2.getDate();
    }
    let thisDay = date2.getFullYear() + '-' + mon2 + '-' + day2;
    this.option.column[2].searchValue = [oldDate, thisDay];*/
  },
  watch: {
    visible(val) {
      if (!this.init) {
        this.init = true
      }
      if (val && this.userOption && this.userOption.data) this.$set(this, 'data', JSON.parse(JSON.stringify(this.userOption.data)))
    },
    "processForm.itemLevel": {
      handler(val) {
        const processConfiguration = this.findObject(this.processOption.column, 'processConfiguration');
        if (!validatenull(val)) {
          if (val == '5') {
            processConfiguration.display = false;
          } else {
            processConfiguration.display = true;
          }
        }
      },
      immediate: true
    },
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        viewBtn: this.vaildData(this.permission.register_view, false),
      };
    },
    userUrl() {
      return this.userOption.userUrl
    },
    customOption() {
      return this.userOption.customOption
    },
  },
  methods: {
    openFlow(row) {
      window.open(row)
    },
    handView(row) {
      getTaskDetail({rowguid: row.rowguid}).then(res => {
        this.obj = res.data.data
        this.materialInfoData = res.data.data.materials
        this.processData = res.data.data.activities
        this.viewVisible = true
      })
    },
    getSubmitArg(msg) {
      saveActivityLinkName(this.saveActivity2(this.processForm)).then((res) => {
        if (!res.data.data) {
          this.$message({
            type: "error",
            message: "流程环节保存失败，请联系管理员"
          });
        } else {
          this.$message({
            type: "success",
            message: "操作成功"
          });
          this.handleClose();
        }
      }).catch(() => {
      });
    },
    baseConfigure(row) {
      this.servExtendForm.itemId = row.itemId;
      selectitemId(this.servExtendForm.itemId).then(res => {
        if (res.data.data != false) {
          this.servExtendForm = res.data.data;
          this.baseConfigVisible = true;//解决由于异步请求导致表单数据延时变化
        } else {
          this.baseConfigVisible = true;
        }
      })
    },
    TJDX() {
      if (validatenull(this.servExtendForm.isLinkSms)) {
        this.$message({
          message: '请选择是否发送环节短信！',
          type: 'error',
        });
        return;
      }
      if (validatenull(this.servExtendForm.isResultSms)) {
        this.$message({
          message: '请选择是否发送办结结果短信！',
          type: 'error',
        });
        return;
      }
      this.servExtendLoading = true;
      submitServExtend(this.servExtendForm).then(() => {
        this.$message({
          message: '配置成功！',
          type: 'success',
        });
        this.baseConfigVisible = false;
        this.servExtendLoading = false;
      }).catch(() => {
        this.$message({
          message: '配置失败！',
          type: 'error',
        });
        this.servExtendLoading = false;
      });
    },
    QXDX() {
      this.servExtendForm = {};
      this.baseConfigVisible = false;
    },
    shiXiangVisible1(row, val) {
      if (row.itemLevel == 6 || row.itemLevel == 7) {
        selectItemId(row.itemId).then(res => {
          if (res.data.data == false) {//新增模板
            this.drawer01 = true;
            if (val == 0) {
              this.subForm.className = "";
              this.subForm.className = "依申请";
            } else if (val == 1) {
              this.subForm.className = "";
              this.subForm.className = "公共服务";
            }
            this.subForm.id = "";
            this.subForm.deptinterId = "";
            this.subForm.remarks = "";
            this.subForm.areaCode = row.areaCode;
            this.subForm.deptCode = row.deptCode;
            this.subForm.deptName = row.deptName;
            this.subForm.itemId = row.itemId;
            this.subForm.servName = row.taskName;
            selectAreaName(this.subForm.deptCode).then(res => {
              this.subForm.areaName = res.data.data;
            });
          } else {//编辑模板
            this.drawer02 = true;
            selectupdate(row.itemId).then(res => {
              this.subForm = res.data.data;
              selectAreaName(res.data.data.deptCode).then(res => {
                this.subForm.areaName = res.data.data;
              })
            })
          }
        });
      } else {
        this.drawer01 = false;
        this.$message({
          message: '该事项的办理系统不属于：（统一申报、统一受理、自建办理）或（统一申报、自建受理、自建办理）',
          type: 'error',
        });
      }

    },
    //新增取消
    QX01() {
      this.drawer01 = false;
    },
    //编辑取消
    QX02() {
      this.drawer02 = false;
      this.onLoad(tis.page);
    },
    //新增提交
    TJ01() {
      if (this.subForm.deptinterId != null && this.subForm.deptinterId != "") {
        addInter(this.subForm).then(res => {
          if (res.data.data == true) {
            this.subForm.id = "";
            /*this.subForm.deptinterId = "";*/
            this.subForm.remarks = "";
            this.drawer01 = false;
            this.$message({
              message: '添加成功！',
              type: 'success',
            });
          } else {
            this.$message({
              message: '添加失败！',
              type: 'error',
            });
          }
        });
      } else {
        this.$message({
          message: '请选择系统名称！',
          type: 'error',
        });
      }
    },
    //编辑提交
    TJ02() {
      if (this.subForm.deptinterId != null && this.subForm.deptinterId != "") {
        update(this.subForm).then(res => {
          if (res.data.data == true) {
            this.subForm.deptinterId = "";
            this.subForm.remarks = "";
            this.drawer02 = false;
            this.$message({
              message: '修改成功！',
              type: 'success',
            });
          } else {
            this.$message({
              message: '修改失败！',
              type: 'error',
            });
          }
        })
      } else {
        this.$message({
          message: '请选择系统名称！',
          type: 'error',
        })
      }
    },
    linkSave() {
      this.handleProcess(this.processForm)
    },
    linkDelete() {
      this.$confirm("确认置空该事项所有环节信息吗？（置空后不可恢复）", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteActivity(this.linkItemId).then(res => {
          if (res.data.data === true) {
            this.$message.success("置空成功");
            this.processForm.processConfiguration = ''
            // this.processForm.itemLevel = '';
            this.processForm.version = 1;
            this.userData = [];
            this.linkDeleteShow = false;
          }
        })
        deleteActivityConfig(this.type.prop, this.processForm.taskId)
      })
    },
    // lincenseSave(){
    //   this.handleSure();
    // },
    // lincenseDelete(){
    //   this.licenseForm.licenseTypeName = "";
    //   //getTaskExtend(this.licenseForm.taskGuid, '','','', '', this.extendType).then(res => {
    //   getTaskBase(this.licenseForm.itemId, '','','', '', this.extendType).then(res => {
    //     if (res.data.data == true) {
    //       //this.licenseVisible = false;
    //       this.$message.success("置空成功")
    //       this.lincenseSaveBtn = true;
    //       this.lincenseDeleteBtn = false;
    //       this.refreshChange();
    //     }
    //   })
    // },
    uploadAfter(res, done, loading, column) {
      let result = res + "";
      if (result.indexOf("Error") != -1) {
        this.$message.error(result.substring(result.indexOf(":") + 1))
      } else {
        if (res != null && res.length > 0) {
          this.errorData = res;
          this.errorBox = true;
        } else {
          this.$message.success('导入成功')
          this.excelBox = false;
        }
      }
      this.refreshChange();
      done();
    },
    userDataSplice(index) {
      this.userData.splice(index, 1);
      // if (this.userData > 0) {
      //   for (let i = 0; i < this.userData.length; i++) {
      //     if (this.userData[0].linkName === this.userData[i].linkName) {
      //       this.processOption.submitBtn = false;
      //     }else {
      //       this.processOption.submitBtn = true;
      //     }
      //   }
      // }else {
      //   this.processOption.submitBtn = true;
      // }
    },
    userDataPush() {
      let result = this.pauseData(this.userData)
      if (result == undefined) {
        this.userData.splice(this.userData.length + 1, 0, {linkSort: this.userData.length + 1, timeLimit: 0});
      } else {
        this.$message.warning("请先填写完整环节信息，再点击新增按钮")
      }
    },
    pauseData(data) {
      for (let i = 0; i < data.length; i++) {
        if ((validatenull(data[i].value) || data[i].value === undefined)
          || (validatenull(data[i].text) || data[i].text === undefined)
          || (validatenull(data[i].linkSort) || data[i].linkSort === undefined)
          || (validatenull(data[i].linkName) || data[i].linkName === undefined)
          || (validatenull(data[i].timeLimit) || data[i].timeLimit === undefined)) {
          return false;
        }
      }
    },
    linkNameChange(val, index) {
      let that = this;
      for (let i = 0; i < that.userData.length - 1; i++) {
        if (val === that.userData[i].linkName) {
          that.$message.warning("输入的环节名称【 " + val + " 】已重复，请重新输入")
          that.processOption.submitBtn = false;
          return false;
        } else if (validatenull(val)) {
          that.processOption.submitBtn = true;
        } else {
          that.processOption.submitBtn = true;
        }
      }
    },
    linkSortChange(val, index) {
      let that = this;
      for (let i = 0; i < that.userData.length - 1; i++) {
        if (val === that.userData[i].linkSort) {
          that.$message.warning("输入的环节排序【 " + val + " 】已重复，已为您自动调整为：" + that.userData.length)
          that.processForm.processConfiguration[that.userData.length - 1].linkSort = that.userData.length;
          return false;
        }
      }
    },
    linkHistory(row) {
      this.linkVersion = row.linkVersion;
      this.linkBox = true;
      this.onLoadVersion(this.pageVersion)
    },
    getActivityList(rowGuid, tableName) {
      getActivityList(rowGuid, tableName).then(res => {
        let data = res.data.data;
        data.forEach(item => {
          this.userData.push({
            linkName: item.activityname,
            timeLimit: item.handleTimelimit
          })
        })
      })
    },
    ToNext() {
      if (this.stepnow < this.steps) {
        if (this.stepnow === 1) {
          if (this.servvCertificate.length == 0) {
            this.$confirm("该事项还未维护证照目录，确认先不维护吗?", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }).then(() => {
              this.stepnow++;
            })
          } else {
            this.stepnow++;
          }
        } else if (this.stepnow === 2) {

        } else {
          this.stepnow++;
        }
      } else {
        return false
      }

    },
    ToPorp() {
      this.stepnow--;
      this.getLicneseTypeNameData(this.rowData.deptCode);
      // this.getLicneseTypeNameJsonArray(this.rowData.deptCode);
    },
    materialShowStatus(row) {
      this.materialTitle = row.taskName + "-材料信息"
      getDetailById(row.id, row.taskType).then(res => {
        this.serviceItem = res.data.data;
        this.materialShow = true;
      });
    },
    // handleSure(){
    //   this.$refs.licenseForm.validate((valid, done) => {
    //     if (valid) {
    //       let data = this.jsonArrayData.filter(ele => ele.CERTYPE_DTL_NAME === this.licenseForm.$licenseTypeName).filter(ele => ele.CERTYPE_DTL_ID === this.licenseForm.licenseTypeName);
    //       if (data.length = 1) {
    //         //getTaskExtend(this.licenseForm.taskGuid, data[0].CERTIFICATE_TYPE_CODE,data[0].CERTIFICATE_TYPE,data[0].CERTYPE_DTL_ID, data[0].CERTYPE_DTL_NAME, this.extendType).then(res => {
    //         getTaskBase(this.licenseForm.itemId, data[0].CERTIFICATE_TYPE_CODE,data[0].CERTIFICATE_TYPE,data[0].CERTYPE_DTL_ID, data[0].CERTYPE_DTL_NAME, this.extendType).then(res => {
    //           if (res.data.data == true) {
    //             //this.licenseVisible = false;
    //             this.$message.success("操作成功")
    //             this.refreshChange();
    //           }else if (res.data.data == "null"){
    //             this.$message.warning("该事项暂无扩展数据，证照数据无法维护。请点击下一步，维护事项环节");
    //             //this.licenseVisible = false;
    //             this.licenseForm.licenseTypeName = "";
    //             this.licenseOption.column[2].rules = [];
    //           }else {
    //             //this.licenseVisible = false;
    //             this.refreshChange();
    //           }
    //           this.lincenseSaveBtn = false;
    //           this.lincenseDeleteBtn = true;
    //           this.NextStep = true
    //           done();
    //         }).catch(() => {
    //           loading();
    //         })
    //       }else if (data.length < 1){
    //         this.$message.warning("未找到该证照，请联系相关人员处理");
    //         done();
    //       }else if (data.length > 1) {
    //         this.$message.warning("证照类型重复，请联系相关人员处理");
    //         done();
    //       }
    //     }
    //   })
    // },
    licenseMaintain(row) {
      this.getLicneseTypeNameData(row.deptCode);
      //this.getLicneseTypeNameJsonArray(row.deptCode);
      this.licenseForm.taskGuid = row.rowGuid;
      this.licenseForm.itemId = row.itemId;
      this.licenseForm.taskName = row.taskName;
      this.licenseForm.licenseTypeName = row.catalogName;
      if (row.catalogName != null && row.catalogName != '' && row.catalogName != undefined) {
        this.lincenseSaveBtn = false;
        this.lincenseDeleteBtn = true;
      } else {
        this.lincenseSaveBtn = true;
        this.lincenseDeleteBtn = false;
      }
      this.NextStep = true
      //this.licenseVisible = true;
    },
    handleRemoveAll() {
      this.licenseLoading = true;
      this.$confirm("确定清空所有已选择证照?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        let row = {
          itemId: this.licenseForm.itemId,
          data: []
        }
        save(row).then(res => {
          if (res.data.code == 200) {
            this.$message.success('证照清空成功')
            this.servvCertificate = [];
            this.jsonArrayData.forEach(item => item.isChoose = false)
          } else {
            this.$message.warning('证照维护失败,请重试')
            this.handleClose()
          }
          this.licenseLoading = false;
        })
      }).catch(() => {
        return false
        this.licenseLoading = false;
      })
    },
    handleSave() {
      this.licenseLoading = true;
      if (!this.verifyLicenseOperationType(this.servvCertificate)) {
        this.licenseLoading = false;
        return;
      }
      let row = {
        itemId: this.licenseForm.itemId,
        data: this.servvCertificate
      }
      save(row).then(res => {
        if (res.data.code == 200) {
          this.$message.success('证照维护保存成功')
        } else {
          this.$message.warning('证照维护失败,请重试')
          this.handleClose()
        }
        this.licenseLoading = false;
      })
    },
    verifyLicenseOperationType(data) {
      for (let i = 0; i < data.length; i++) {
        if (validatenull(data[i].operationType)) {
          this.$message.error('第' + (i + 1) + '行，' + data[i].certypeDtlName + '的操作类型不能为空！');
          return false;
        }
      }
      return true;
    },
    changeChooseRight(item, index) {
      this.servvCertificate.splice(index, 1)
      this.jsonArrayData.forEach((listItem, i) => {
        if (listItem.CERTYPE_DTL_ID === item.certypeDtlId) {
          this.jsonArrayData[i].isChoose = false
        }
      })
    },
    changeChooseLeft(item) {
      if (item.isChoose) {
        item.isChoose = !item.isChoose
        // let changeItem = this.servvCertificate.find(listItem => (listItem.certypeDtlId === item.CERTYPE_DTL_ID))
        this.servvCertificate.forEach((listItem, i) => {
          if (item.CERTYPE_DTL_ID === listItem.certypeDtlId) {
            this.servvCertificate.splice(i, 1)
          }
        })
      } else {
        item.isChoose = !item.isChoose
        this.servvCertificate.push({
          itemId: this.licenseForm.itemId,
          certypeDtlId: item.CERTYPE_DTL_ID,
          certypeDtlName: item.CERTYPE_DTL_NAME,
          category: item.CATEGORY,
          certificateTypeCode: item.CERTIFICATE_TYPE_CODE,
          certificateType: item.CERTIFICATE_TYPE,
          issueDept: item.ISSUE_DEPT,
          issueDeptCode: item.ISSUE_DEPT_CODE,
        })
      }

    },
    getLicneseTypeNameData(deptCode) {
      getServCertificateByItem(this.linkItemId).then(res => {
        if (res.data.code == 200) {
          this.servvCertificate = res.data.data
          getLicneseTypeNameData(deptCode).then(res => {
            if (res.data.data == "catalog-token") {
              this.$message.warning("证照目录接口异常!1111111111")
              return false;
            } else if (res.data.data == "catalog-derror") {
              this.$message.warning("证照目录接口异常!")
              return false;
            } else if (res.data.data == "data-error") {
              this.$message.warning("证照目录接口异常!")
              return false;
            } else if (res.data.data == "rows-null") {
              this.$message.warning("证照目录加载失败!")
              return false;
            } else if (res.data.data == "catalog-json-error") {
              this.$message.warning("证照目录接口异常!")
              return false;
            } else {
              const data = this.findObject(this.licenseOption.column, 'licenseTypeName');
              data.dicData = res.data.data.labelList;
              this.jsonArrayData = res.data.data.dataList.map(item => {
                item.isChoose = false
                for (let i = 0; i < this.servvCertificate.length; i++) {
                  if (item.CERTYPE_DTL_ID === this.servvCertificate[i].certypeDtlId && item.CERTIFICATE_TYPE_CODE === this.servvCertificate[i].certificateTypeCode) {
                    item.isChoose = true
                  }
                }
                return item
              })
            }
          })
        } else {
          this.$message.warning('获取已维护证照信息失败')
        }
      })
    },
    // getLicneseTypeNameJsonArray(deptCode) {
    //   getLicneseTypeNameJsonArray(deptCode).then(res => {
    //     if (res.data.data == "rows-null") {
    //       this.$message.warning("证照目录加载失败!")
    //       return false;
    //     }else {
    //       this.jsonArrayData = res.data.data;
    //     }
    //   })
    // },
    linkSelect(item, row, index) {
      this.$set(this.userData[index], 'linkName', item.value)
      this.processForm.processConfiguration = this.userData
    },
    deleteAll(row) {
      remove({deploymentId: row.deploymentId}).then(() => {
        deleteActivity(row.key, row.version)
      })
      removeByModelKey(row.modelKey)
    },
    getItemLevel(areacode) {
      getDictionary({code: 'itemLevel'}).then(res => {
        const data = res.data.data
        if (areacode == '620000') {
          data.splice(3, 1)
          if (this.type.prop == 'task_general_basic') {
            data.splice(3, 1)
          }
        }/*else if (this.type.prop == 'task_general_basic'){
          data.splice(4,1)
        }*/
        const column = this.findObject(this.processOption.column, "itemLevel");
        column.dicData = data;
      })
    },
    getLinkName() {
      getDictionary({code: 'linkName'}).then(res => {

        let resData = [];
        const data = res.data.data;

        for (let i = 0; i < this.userData.length; i++) {
          for (let j = 0; j < data.length; j++) {
            if (this.userData[i].linkName === data[j].dictValue) {
              data.splice(j, 1);
            }
          }
        }
        data.forEach(item => {
          resData.push({
            value: item.dictValue,
            desc: item.dictValue
          })
        })
        this.linkList = resData;
      })
    },
    linkListFetch(query, cd) {
      getDictionary({code: 'linkName'}).then(res => {
        let resData = [];
        const data = res.data.data;
        for (let i = 0; i < this.userData.length; i++) {
          for (let j = 0; j < data.length; j++) {
            if (this.userData[i].linkName === data[j].dictValue) {
              data.splice(j, 1);
            }
          }
        }
        data.forEach(item => {
          resData.push({
            value: item.dictValue,
            desc: item.dictValue
          })
        })
        cd(resData);
      })
    },
    handleClose() {
      this.formShow = false;
      this.drawer01 = false;
      this.drawer02 = false;
      this.processVisible = false;
      this.processForm.itemLevel = '';
      this.processForm.processConfiguration = '';
      this.userData = [];
      this.stepnow = 1;
      const processConfiguration = this.findObject(this.processOption.column, 'processConfiguration');
      processConfiguration.display = true;
      this.linkDeleteShow = false;
      this.activityData = [];
      this.jsonArrayData = [];
      this.servvCertificate = [];
      this.onLoad(this.page);
    },
    baseConfigClose() {
      this.servExtendForm = {};
      this.baseConfigVisible = false;
    },
    channelInputLimit(e) {
      let key = e.key;
      if (key === '.' || key === ',') {
        e.returnValue = false
        this.$message.warning("请不要输入小数")
        return false
      }
      return true;
    },
    handleProcess(form) {
      this.linkLoading = true;
      this.$refs.processForm.validate((valid, done) => {
        if (valid) {
          let itemLevel = this.processForm.itemLevel;
          //如果是无须自建  只保存办理系统类型
          if (itemLevel == '5') {
            if (this.userData.length > 0) {
              this.testLinkSave(form, done)
            } else {
              taskActivityConfig(this.type.prop, this.processForm.taskId, this.processForm.itemLevel, null).then(res => {
                this.$message.success("操作成功");
                done();
                this.linkLoading = false;
                this.handleClose();
              });
            }
          } else if (itemLevel === '3' && this.userData.length > 0) {
            this.testLinkSave(form, done)
          } else if (itemLevel === '3' && this.userData.length === 0) {
            this.$message.error('环节配置信息没有输入完整');
            done();
            this.linkLoading = false;
          } else {
            //如果是国垂、省垂、市自建这三种类型 不做必须维护控制，但是如果维护了环节节点，还按照规则进行校验
            if (this.userData.length > 0) {
              this.testLinkSave(form, done)
            } else {
              //没有选择环节 只保存业务办理系统类型
              taskActivityConfig(this.type.prop, this.processForm.taskId, this.processForm.itemLevel, null).then(res => {
                this.$message.success("操作成功");
                done();
                this.linkLoading = false;
                this.handleClose();
              });
            }
          }
        }
      })
    },
    testLinkSave(form, done) {
      let timeLimit = 0;
      for (let i = this.userData.length - 1; i >= 0; i--) {
        if ((this.userData[i].value == null || this.userData[i].value == '') ||
          (this.userData[i].text == null || this.userData[i].text == '') ||
          (this.userData[i].timeLimit < 0 || this.userData[i].timeLimit == null) ||
          (this.userData[i].linkName == null || this.userData[i].linkName == '') ||
          (this.userData[i].linkSort == null || this.userData[i].linkSort == '')) {
          this.$message.error('第' + (i + 1) + '环节配置信息没有输入完整');
          done();
          this.linkLoading = false;
          return;
        }
        timeLimit += this.userData[i].timeLimit
      }
      if ((JSON.stringify(this.userData).indexOf("办结") == -1) || (JSON.stringify(this.userData).indexOf("受理") == -1)) {
        this.$message.error('环节配置没有受理或办结环节');
        done();
        this.linkLoading = false;
        return;
      }
      let data = this.userData.sort(this.sortBy('linkSort'));
      if (data[0].linkName != '受理' || data[this.userData.length - 1].linkName != '办结') {
        this.$message.error('第一个环节必须是\"受理\",最后一个环节必须是\"办结\"');
        done();
        this.linkLoading = false;
        return;
      }
      if (this.rowData.projectType == '1') {
        if (data[this.userData.length - 1].timeLimit != 1) {
          this.$message.error('办结环节的环节办理时限必须是1');
          done();
          this.linkLoading = false;
          return;
        }
        for (let i = 0; i < data.length - 1; i++) {
          if (data[i].timeLimit != 0) {
            this.$message.error('第' + (i + 1) + '环节的环节办理时限必须是0');
            done();
            this.linkLoading = false;
            return;
          }
        }
      }
      if (timeLimit.toString().indexOf(".") !== -1) {
        this.$message.warning("环节办理时限不能有小数");
        done();
        this.linkLoading = false;
        return;
      }
      let newName = this.userData.map(item => item.linkName);
      let setName = new Set(newName)
      let newSort = this.userData.map(item => item.linkSort);
      let setSort = new Set(newSort)
      if (setSort.size != newSort.length || setName.size != newName.length) {
        /*this.$confirm("有重复的环节名称或重复的环节排序，不会生成流程，请点击编辑流程按钮进行流程生成，是否继续保存环节信息？", {
            confirmButtonText: "是",
            cancelButtonText: "否",
            distinguishCancelAndClose: true,
            type: "warning"
        }).then(() => {
            saveActivityLinkName(this.saveActivity(form)).then((res) => {
                if (!res.data.data) {
                    this.$message({
                        type: "error",
                        message: "流程环节保存失败，请联系管理员"
                    });
                }else {
                    this.$message({
                        type: "success",
                        message: "操作成功"
                    });
                    this.handleClose();
                }
                done();
            }).catch(() => {
                done();
            });
        }).catch(() => {})*/
        this.$alert('有重复的环节名称或重复的环节排序，请点击编辑流程按钮生成流程', '提示', {
          confirmButtonText: '确定',
        });
        this.linkLoading = false;
      } else {
        if (timeLimit > this.rowData.promiseDay) {
          this.$confirm("您维护的环节总时限为" + timeLimit + "，超过了该事项的承诺办结时限" + this.rowData.promiseDay + "，确认保存吗？", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(() => {
            saveActivityLinkName(this.saveActivity(form)).then((res) => {
              if (res.data.data) {
                //开启流程
                // this.startFlow(form)
                this.$message({
                  type: "success",
                  message: "操作成功"
                });
              } else {
                this.$message({
                  type: "error",
                  message: "操作失败，请联系管理员"
                });
              }
              done();
              this.linkLoading = false;
              this.handleClose();
            }, error => {
              window.console.log(error);
              this.linkLoading = false;
            });
          }).catch(() => {
            done();
            this.linkLoading = false;
          })
        } else {
          saveActivityLinkName(this.saveActivity(form)).then((res) => {
            if (res.data.data) {
              //开启流程
              // this.startFlow(form)
              this.$message({
                type: "success",
                message: "操作成功"
              });
            } else {
              this.$message({
                type: "error",
                message: "操作失败，请联系管理员"
              });
            }
            done();
            this.linkLoading = false;
            this.handleClose();
          }, error => {
            window.console.log(error);
            this.linkLoading = false;
          });
        }
      }
    },
    createRandomLetter() {
      let str = "";
      let arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
      for (let i = 0; i < 8; i++) {
        let pos = Math.round(Math.random() * (arr.length - 1));
        str += arr[pos]
      }
      this.itemRandomLetter = str;
    },
    handleSelect(index, ref) {
      this.selectIndex = index
      this.defaultChecked = this.userData[index];
      this.$refs[ref].visible = true
    },
    handleSelectConfirm(id, name, deptIds, deptNames, deptCodes, accounts, thirdIds) {
      this.$set(this.userData[this.selectIndex], 'value', id)
      this.$set(this.userData[this.selectIndex], 'text', name)
      this.$set(this.userData[this.selectIndex], 'deptIds', deptIds)
      this.$set(this.userData[this.selectIndex], 'deptNames', deptNames)
      this.$set(this.userData[this.selectIndex], 'deptCodes', deptCodes)
      this.$set(this.userData[this.selectIndex], 'accounts', accounts)
      this.$set(this.userData[this.selectIndex], 'thirdIds', thirdIds)
      this.processForm.processConfiguration = this.userData
    },
    saveActivity(data) {
      let nodes = [];
      let json = {};
      for (let i = 0; i < data.processConfiguration.length; i++) {
        let usersData = {};
        let users = [];
        let nodeData = {};
        usersData.type = 'user';
        usersData.value = data.processConfiguration[i].value;
        usersData.userName = data.processConfiguration[i].text;
        usersData.deptIds = data.processConfiguration[i].deptIds;
        usersData.deptNames = data.processConfiguration[i].deptNames;
        usersData.deptCodes = data.processConfiguration[i].deptCodes;
        usersData.timeLimit = data.processConfiguration[i].timeLimit;
        usersData.account = data.processConfiguration[i].accounts;
        usersData.thirdId = data.processConfiguration[i].thirdIds;
        usersData.activityDuty = '测试描述';
        usersData.examine = '测试标准';
        usersData.linkSort = data.processConfiguration[i].linkSort
        users.push(usersData)
        nodeData.users = users;
        nodeData.name = data.processConfiguration[i].linkName;
        nodes.push(nodeData);
      }
      json.taskId = data.taskId;
      json.id = data.processId;
      json.linkItemId = data.linkItemId;
      json.linkModelDeploymentId = data.linkModelDeploymentId;
      json.name = data.processName;
      json.itemName = data.itemName;
      json.nodes = nodes;
      json.version = data.version;
      json.linkSysType = this.processForm.itemLevel;
      json.linkItemCode = this.processForm.linkItemCode;
      json.areaCode = this.processForm.areaCode;
      json.taskHandleItem = this.rowData.ywcode;
      json.taskId = this.rowData.rowguid;
      json.isCustomFlow = "0";
      return json;
    },
    saveActivity2(data) {
      let activiyJson = this.saveActivity(data);

      activiyJson.isCustomFlow = "1";
      return activiyJson;
    },
    //开启流程
    startFlow(data) {
      let nodes = [];
      let json = {};
      for (let i = 0; i < data.processConfiguration.length; i++) {
        let usersData = {};
        let users = [];
        let nodeData = {};
        let dataValue = [];
        let dataText = [];
        if (data.processConfiguration[i].value.includes(',')) {
          dataValue = data.processConfiguration[i].value.split(',');
          dataText = data.processConfiguration[i].text.split(',');
          for (let j = 0; j < dataValue.length; j++) {
            usersData = {};
            usersData.type = 'user';
            usersData.value = dataValue[j];
            usersData.text = dataText[j];
            users.push(usersData)
          }
        } else {
          usersData.type = 'user';
          usersData.value = data.processConfiguration[i].value;
          usersData.text = data.processConfiguration[i].text;
          users.push(usersData)
        }
        nodeData.users = users;
        nodeData.name = data.processConfiguration[i].linkName;
        nodeData.sort = data.processConfiguration[i].linkSort;
        nodes.push(nodeData);
        nodes.sort(this.sortBy('sort', false));
      }
      json.id = data.processId;
      json.name = data.processName;
      json.itemName = data.itemName;
      json.formKey = 'business';
      json.modelKey = data.processId;
      json.category = '1427249606591946753';
      json.nodes = nodes;
      json.row = this.rowData;
      let areaCode = this.rowData.areaCode;
      areaCode = areaCode.substring(0, 6);
      //if( this.processForm.itemLevel === '3'){ //areaCode == '620000' &&
      console.log("产生了流程")
      buildFlow(json).then((res) => {
        taskActivityConfig(this.type.prop, this.processForm.taskId, this.processForm.itemLevel, res.data.data).then(res => {
          this.handleClose();
        });
      })
      /* }else {
         console.log("没产生")
         taskActivityConfig(this.type.prop, this.processForm.taskId, this.processForm.itemLevel, null).then(res => {
           this.handleClose();
         });
       }*/

    },
    //修改时主动赛值，防止数据不变化
    timeInput(data, index) {
      this.$set(this.userData[index], 'timeLimit', data)
      this.processForm.processConfiguration = this.userData
    },
    sortInput(data, index) {
      this.$set(this.userData[index], 'linkSort', data)
      this.processForm.processConfiguration = this.userData
    },
    getListKey() {
      this.deployMentName = [];
      this.deployMentKey = [];
      getDeploymentListByKey('', '').then(res => {
        res.data.data.forEach(ele => {
          this.deployMentName.push(ele.name)
          this.deployMentKey.push(ele.key)
        })
      })
    },
    itemLevel(row) {
      this.rowData = row;
      this.linkItemId = row.itemId;
      this.itemTitle = row.taskName;
      this.linkTabType = this.linkOption.column[0];
      this.processForm.taskId = row.id;
      this.processForm.linkItemId = row.itemId;
      this.processForm.itemLevel = row.itemLevel;
      this.processForm.itemName = row.taskName + "-流程";
      this.processForm.linkItemCode = row.taskCode;
      this.processForm.areaCode = row.areacode;
      this.getItemLevel(row.areaCode);
      getActivityList(row.itemId).then(res => {
        let data = res.data.data;
        this.activityPush(data).then(() => {
          // if (row.itemLevel == '' || row.itemLevel == null || row.itemLevel == undefined) {
          //   console.log('LLL==>')
          //   this.processForm.processName = "process_" + row.taskName + "_" + this.itemRandomLetter + "_流程";
          //   this.itemActivity(this.activityData);
          // } else {
          this.userData = [];
          this.processOption.emptyBtn = false;
          getActivityLinkName(row.itemId).then(res => {
            const data1 = res.data.data;
            if (data1.length > 0) {
              this.processForm.processName = data1[0].linkModelKey
              this.pushUserData(data1).then(() => {
                //this.processForm.version = data1[0].linkVersion + 1;
                this.processForm.processConfiguration = this.userData
                this.visible = true
              })
              this.linkDeleteShow = true;
            } else {
              this.processForm.processName = "process_" + row.taskName + "_" + this.itemRandomLetter + "_流程";
              //this.processForm.version = 1;
            }
          })

        })
      })
      this.processVisible = true;
    },

    isSendsms(row, isfs) {
      let isfsmsg = "";
      if (isfs == "1") {
        isfsmsg = "确认启用短信吗？";
      } else {
        isfsmsg = "确认禁用短信吗？";
      }
      this.$confirm(isfsmsg, {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        saveIsSendsms(this.type.prop, row.id, isfs).then(res => {
          this.$message.success("操作成功");
          this.refreshChange();
        });
      })

    },

    activityPush(data) {
      return new Promise((resolve) => {
        data.forEach(item => {
          this.activityData.push({
            linkName: item.activityname,
            timeLimit: item.handleTimelimit,
          })
        })
        resolve(this.activityData)
      })
    },
    pushUserData(data) {
      return new Promise((resolve) => {
        data.map(d => {
          this.userData.push({
            text: d.linkUserName,
            linkName: d.linkProcessName,
            value: d.linkUserId,
            deptIds: d.linkDeptId,
            deptNames: d.linkDeptName,
            timeLimit: d.linkHandleTimeLimit,
            linkSort: d.linkSort,
            userName: d.linkUserName,
            thirdIds: d.linkThirdId,
            deptCodes: d.linkDeptCode,
            accounts: d.linkAccount,
          })
        })
        this.userData.sort(function (a, b) {
          if (a.linkSort < b.linkSort) {
            return -1;
          } else if (a.linkSort > b.linkSort) {
            return;
          }
          return 0;
        })
        resolve(this.userData)
      })
    },
    linkSort(sort) {
      return function (a, b) {
        let data1 = a[sort];
        let data2 = b[sort];
        return data1 - data2;
      }
    },
    sortBy(attr, rev) {
      if (rev === undefined) {
        rev = 1;
      } else {
        rev = (rev) ? 1 : -1;
      }
      return function (a, b) {
        a = a[attr];
        b = b[attr];
        if (a < b) {
          return rev * -1;
        }
        if (a > b) {
          return rev * 1;
        }
        return 0;
      }
    },
    itemActivity(activityData) {
      if (activityData.length > 1) {
        if (activityData[0].linkSort === activityData[1].linkSort) {
          activityData.sort(this.linkSort('linkSort'))
        }
      }
      for (let i = 0; i < activityData.length; i++) {
        // if (activityData[i].linkName === '受理') {
        //
        // }else if (activityData[i].linkName === '办结'){
        //
        // }else {
        //
        // }
        this.userData.splice(this.userData.length - 1, 0, activityData[i])
      }
      this.processOption.column[1].disabled = false;
      this.processOption.column[2].disabled = false;
      this.processForm.version = 1;
    },
    guideShowStatus(row) {
      getDetailById(row.id, row.taskType).then(res => {
        this.serviceItem = res.data.data;
        this.guideShow = true;
      });
    },
    historyEvent(row) {
      this.serviceHistory = row;
      this.eventHistoryList = row.taskName + '-历史版本事项列表';
      this.enentHistoryShow = true;
    },
    handleChange(column) {
      if (column.prop == "task_public_basic") {
        this.extendType = "task_public_extend"
      } else {
        this.extendType = "task_general_extend"
      }
      this.search.servDeptCode = null;
      this.query.servDeptCode = null;
      this.type = column;
      this.refreshChange();
    },
    handleLinkChange(column) {
      this.linkTabType = column;
    },
    resetForm() {
      this.licenseForm.licenseTypeName = '';
      this.refreshChange();
    },

    loadOptions({action, parentNode, callback, searchQuery}) {
      if (action === LOAD_CHILDREN_OPTIONS) {
        regionPermissionLazy(parentNode.id).then(res => {
          let list = res.data.data;
          if (list.length > 0) {
            let arr = [];
            list.forEach(item => {
              let obj = {};
              obj.id = item.uniScid;
              obj.label = item.name;
              if (item.hasChildren) {
                obj.children = null;
              }
              arr.push(obj);
            });
            parentNode.children = arr;
          }
        });
        callback();
      }
    },
    asyncOptions({action, searchQuery, callback}) {
      if (action === ASYNC_SEARCH) {
        this.searchQuery = searchQuery;
        filterTreeByKeyWord(searchQuery, this.userInfo.area_code).then(res => {
          const data = res.data.data;
          this.handleLeafNode(data);
          callback(null, data);
        })
      } else if (action === LOAD_CHILDREN_OPTIONS) {
        callback();
      }
    },
    handleLeafNode(list) {
      if (list.length > 0) {
        list.forEach(item => {
          if (!item.hasChildren) {
            delete item.children;
          } else {
            this.handleLeafNode(item.children);
          }
        });
      }
    },
    assetTreeKeyDown() {
      this.isAsync = true;
      this.defaultExpandLevel = 6;
    },
    openTreeSelect() {
      this.isAsync = false;
      this.defaultExpandLevel = 1;
      //this.initDeptTree();
    },
    closeTreeSelect() {
      this.isAsync = false;
      this.defaultExpandLevel = 1;
      this.initDeptTree();
    },
    assetTreeKeyUp(e) {
      if (!e.target.value) {
        this.isAsync = false;
        this.defaultExpandLevel = 1;
        this.initDeptTree();
      }
    },
    initDeptTree() {
      getRegionList("000000000000").then(res => {
        const data = res.data.data;
        if (data.length > 0) {
          let arr = [];
          data.forEach(item => {
            let obj = {};
            obj.id = item.code;
            obj.label = item.name;
            if (item.hasChildren) {
              obj.children = null;
            } else {
              obj.children = [];
            }
            if (item.dataType == 'dept') {
              obj.disabled = false;
            } else {
              obj.disabled = true;
            }
            arr.push(obj);
          });
          this.deptTreeData = arr;
        }
      })
    },

    searchReset() {
      console.log("清空")
      this.search = {};
      this.search.servDeptCode = null;
      /*this.option.column[2].searchValue = [null, null];*/
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      params.servDeptCode = this.search.servDeptCode;
      /*if (Array.isArray(params.versionDate)) {
        params.startDate = params.versionDate[0];
        params.startEndDate = params.versionDate[1];
        params.versionDate = null;
      }*/
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      console.log("切换。。。")
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      if (Array.isArray(params.servDeptCode)) {
        params.servDeptCode = params.servDeptCode.join(',');
      }
      /*if(params.versionDate !== undefined){
        params.startDate = params.versionDate[0];
        params.startEndDate = params.versionDate[1];
        params.versionDate = null;
      }*/
      /*if(params.startDate === undefined){//给caseDoDate默认值当前日期前7天，清空后去除默认值
        params.startDate = this.option.column[2].searchValue[0];
        params.startEndDate = this.option.column[2].searchValue[1];
        params.versionDate = null;
      }*/
      if (fitletaskName(this.query.taskName, this)
        && fitleTaskCodeOrTaskHandleItem(this.query.taskCodeOrTaskHandleItem, this)) {
        if (optionItem.lazy) {
          getPage(page.currentPage, page.pageSize, Object.assign(params, this.query), this.type.prop).then(res => {
            const data = res.data.data;
            this.page.total = data.total;
            this.data = data.records;
            this.loading = false;
          });
        } else {
          getPage(page.currentPage, page.pageSize, Object.assign(params, this.query), this.type.prop, this.extendType).then(res => {
            const data = res.data.data;
            this.page.total = data.total;
            this.data = data.records;
            this.loading = false;
          });
        }
      } else {
        this.loading = false;
      }
    },
    currentActivityChange(currentPage) {
      this.pageActivity.currentPage = currentPage;
    },
    sizeActivityChange(pageSize) {
      this.pageActivity.pageSize = pageSize;
    },
    onLoadActivity(page, params = {}) {
      this.loadingActivity = true;
      const values = {
        ...params,
        linkItemId: this.linkItemId
      }
      selectActivityPage(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(res => {
        const data = res.data.data;
        this.pageActivity.total = data.total;
        this.dataActivity = data.records;
        this.loadingActivity = false;
      })
    },
    onLoadVersion(page, params = {}) {
      this.loadingVersion = true;
      const values = {
        ...params,
        linkItemId: this.linkItemId,
        linkVersion: this.linkVersion
      }
      selectActivityVersionPage(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(res => {
        const data = res.data.data;
        this.pageVersion.total = 0;
        this.dataVersion = data.records;
        this.loadingVersion = false;
      })
    },
    editFlow() {
      let newName = this.userData.map(item => item.linkName);
      let setName = new Set(newName)
      let newSort = this.userData.map(item => item.linkSort);
      let setSort = new Set(newSort)
      if (setName.size == newName.length) {
        //this.$alert( "存在环节名称相同，并且环节名称相同的环节序号相同才可以编辑流程");
        this.$alert('存在环节名称相同，并且环节名称相同的环节序号相同才可以编辑流程', '提示', {
          confirmButtonText: '确定',
          callback: action => {
            /*this.$message({
                type: 'info',
                message: `action: ${ action }`
            });*/
          }
        });
        return;
      }
      for (let i = 0; i < this.userData.length; i++) {
        for (let j = 0; j < this.userData.length; j++) {
          if (i != j) {
            if (this.userData[i].linkName == this.userData[j].linkName) {
              if (this.userData[i].linkSort != this.userData[j].linkSort) {
                this.$message({
                  type: "warning",
                  message: "环节名称相同，环节序号就必须相同"
                });
                return;
              }
            }
          }
        }
      }
      getDeploymentById(this.rowData.ywcode).then(res => {
        const data = res.data.data;
        if (!validatenull(data)) {
          this.rowData.modelId = data[0].id;
        }
        this.formShow = true;
      })
    },
    flowClose() {
      this.formShow = false;
    }
  },
};
</script>
<style scoped lang="scss">
@import "@/styles/set.scss";

/deep/ .el-drawer__body {
  overflow: auto;
  /* overflow-x: auto; */
}

/deep/ .avue-crud__menu {
  //display: none;
}

/deep/ .el-upload-list {
  display: none;
}
</style>
<style scoped lang="scss">
* {
  margin-block-start: 0;
  margin-block-end: 0;
}

.step_box_card {
  background: #fff;
  height: calc(100% - 170px);
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  border-radius: 10px;
  overflow-y: hidden;
  box-sizing: border-box;
  padding: 35px;
}

.step_box_card > div {
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  padding-right: 10px;
  box-sizing: border-box;
}

.foot_button_group {
  text-align: center;
  margin-top: 30px;
}

.zz_card_box {
  width: 100%;
  height: calc(100% - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 10px;

  .card_left, .card_right {
    width: 50%;
    height: 100%;
    overflow-y: auto;

    ul {
      padding: 0;
      margin: 0;

      .card_item {
        list-style: none;
        width: 47%;
        margin-right: 2%;
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        box-sizing: border-box;
        border: 1px solid #fff;
        box-shadow: 0px 0px 10px rgba(0, 0, 0, .12);
        border-radius: 8px;
        padding: 6px 2%;
        margin-bottom: 16px;
        cursor: pointer;
        position: relative;

        .icon {
          background: #1e9fff;
          width: 40px;
          height: 40px;
          text-align: center;
          line-height: 35px;
          border-radius: 37px;
          flex-shrink: 0;
          margin-right: 13px;

          img {
            width: 16px;
          }
        }

        &:hover, &.choose {
          border-color: #1e9fff;
        }

        &:nth-child(2n) {
          margin-right: 0;
        }

        &.choose::before {
          content: '';
          width: 0;
          height: 0;
          display: block;
          position: absolute;
          border-width: 13px;
          border-color: transparent #1e9fff #1e9fff transparent;
          border-style: solid;
          right: 0;
          bottom: 0;
        }

        &.choose::after {
          content: '';
          display: block;
          background: url(/img/dh.png);
          position: absolute;
          width: 10px;
          height: 12px;
          background-size: 100% 100%;
          right: 3px;
          bottom: 3px;
        }

        &.add_choose::after {
          content: '';
          display: block;
          background: url(/img/add.png);
          position: absolute;
          width: 12px;
          height: 12px;
          background-size: 100% 100%;
          right: 3px;
          bottom: 3px;
        }

        &.change_choose::after {
          content: '';
          display: block;
          background: url(/img/change.png);
          position: absolute;
          width: 12px;
          height: 12px;
          background-size: 100% 100%;
          right: 3px;
          bottom: 3px;
        }

        &.cancel_choose::after {
          content: '';
          display: block;
          background: url(/img/cancel.png);
          position: absolute;
          width: 12px;
          height: 12px;
          background-size: 100% 100%;
          right: 3px;
          bottom: 3px;
        }

        &.abolish_choose::after {
          content: '';
          display: block;
          background: url(/img/abolish.png);
          position: absolute;
          width: 12px;
          height: 12px;
          background-size: 100% 100%;
          right: 3px;
          bottom: 3px;
        }
      }
    }

    .img_box {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;

      img {
        width: 140px;
        margin-bottom: 20px;
      }

      p {
        text-align: center;
        width: 100%;
        color: #999;
      }
    }
  }

  .card_left {
    border-right: 1px solid #e5e5e5;
  }

  .card_right {
    width: 48%;
    margin-left: 2%;
  }
}

.zz_btn_box {
  width: 100%;
  height: 60px;
  text-align: center;
}
</style>
